<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: samples/dnn/text_detection.cpp</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">samples/dnn/text_detection.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">    Text detection model: https://github.com/argman/EAST</span></div><div class="line"><span class="comment">    Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">    Text recognition models can be downloaded directly here:</span></div><div class="line"><span class="comment">    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing</span></div><div class="line"><span class="comment">    and doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">    How to convert from pb to onnx:</span></div><div class="line"><span class="comment">    Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py</span></div><div class="line"><span class="comment">    import torch</span></div><div class="line"><span class="comment">    from models.crnn import CRNN</span></div><div class="line"><span class="comment">    model = CRNN(32, 1, 37, 256)</span></div><div class="line"><span class="comment">    model.load_state_dict(torch.load(&#39;crnn.pth&#39;))</span></div><div class="line"><span class="comment">    dummy_input = torch.randn(1, 1, 32, 100)</span></div><div class="line"><span class="comment">    torch.onnx.export(model, dummy_input, &quot;crnn.onnx&quot;, verbose=True)</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">    For more information, please refer to doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown and doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;fstream&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../d1/d4f/imgproc_2include_2opencv2_2imgproc_8hpp.html">opencv2/imgproc.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../d4/dd5/highgui_8hpp.html">opencv2/highgui.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="../../d9/d8c/dnn_8hpp.html">opencv2/dnn.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../df/d57/namespacecv_1_1dnn.html">cv::dnn</a>;</div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span>* keys =</div><div class="line">    <span class="stringliteral">&quot;{ help  h              | | Print help message. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ input i              | | Path to input image or video file. Skip this argument to capture frames from a camera.}&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ detModel dmp         | | Path to a binary .pb file contains trained detector network.}&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ width                | 320 | Preprocess input image by resizing to a specific width. It should be multiple by 32. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ height               | 320 | Preprocess input image by resizing to a specific height. It should be multiple by 32. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ thr                  | 0.5 | Confidence threshold. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ nms                  | 0.4 | Non-maximum suppression threshold. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ recModel rmp         | | Path to a binary .onnx file contains trained CRNN text recognition model. &quot;</span></div><div class="line">        <span class="stringliteral">&quot;Download links are provided in doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown}&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ RGBInput rgb         |0| 0: imread with flags=IMREAD_GRAYSCALE; 1: imread with flags=IMREAD_COLOR. }&quot;</span></div><div class="line">    <span class="stringliteral">&quot;{ vocabularyPath vp    | alphabet_36.txt | Path to benchmarks for evaluation. &quot;</span></div><div class="line">        <span class="stringliteral">&quot;Download links are provided in doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown}&quot;</span>;</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> fourPointsTransform(<span class="keyword">const</span> <a name="_a0"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; frame, <span class="keyword">const</span> <a name="_a1"></a><a class="code" href="../../db/d4e/classcv_1_1Point__.html">Point2f</a> vertices[], <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; result);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    <span class="comment">// Parse command line arguments.</span></div><div class="line">    <a name="_a2"></a><a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html">CommandLineParser</a> parser(argc, argv, keys);</div><div class="line">    parser.about(<span class="stringliteral">&quot;Use this script to run TensorFlow implementation (https://github.com/argman/EAST) of &quot;</span></div><div class="line">                 <span class="stringliteral">&quot;EAST: An Efficient and Accurate Scene Text Detector (https://arxiv.org/abs/1704.03155v2)&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span> (argc == 1 || parser.has(<span class="stringliteral">&quot;help&quot;</span>))</div><div class="line">    {</div><div class="line">        parser.printMessage();</div><div class="line">        <span class="keywordflow">return</span> 0;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordtype">float</span> confThreshold = parser.get&lt;<span class="keywordtype">float</span>&gt;(<span class="stringliteral">&quot;thr&quot;</span>);</div><div class="line">    <span class="keywordtype">float</span> nmsThreshold = parser.get&lt;<span class="keywordtype">float</span>&gt;(<span class="stringliteral">&quot;nms&quot;</span>);</div><div class="line">    <span class="keywordtype">int</span> width = parser.get&lt;<span class="keywordtype">int</span>&gt;(<span class="stringliteral">&quot;width&quot;</span>);</div><div class="line">    <span class="keywordtype">int</span> height = parser.get&lt;<span class="keywordtype">int</span>&gt;(<span class="stringliteral">&quot;height&quot;</span>);</div><div class="line">    <span class="keywordtype">int</span> imreadRGB = parser.get&lt;<span class="keywordtype">int</span>&gt;(<span class="stringliteral">&quot;RGBInput&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> detModelPath = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;detModel&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> recModelPath = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;recModel&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> vocPath = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;vocabularyPath&quot;</span>);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (!parser.check())</div><div class="line">    {</div><div class="line">        parser.printErrors();</div><div class="line">        <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// Load networks.</span></div><div class="line">    <a name="a3"></a><a class="code" href="../../db/de0/group__core__utils.html#gaf62bcd90f70e275191ab95136d85906b">CV_Assert</a>(!detModelPath.empty() &amp;&amp; !recModelPath.empty());</div><div class="line">    <a name="_a4"></a><a class="code" href="../../d8/ddc/classcv_1_1dnn_1_1TextDetectionModel__EAST.html">TextDetectionModel_EAST</a> detector(detModelPath);</div><div class="line">    detector.setConfidenceThreshold(confThreshold)</div><div class="line">            .setNMSThreshold(nmsThreshold);</div><div class="line"></div><div class="line">    <a name="_a5"></a><a class="code" href="../../de/dee/classcv_1_1dnn_1_1TextRecognitionModel.html">TextRecognitionModel</a> recognizer(recModelPath);</div><div class="line"></div><div class="line">    <span class="comment">// Load vocabulary</span></div><div class="line">    <a class="code" href="../../db/de0/group__core__utils.html#gaf62bcd90f70e275191ab95136d85906b">CV_Assert</a>(!vocPath.empty());</div><div class="line">    std::ifstream vocFile;</div><div class="line">    vocFile.open(<a name="a6"></a><a class="code" href="../../d6/dba/group__core__utils__samples.html#ga3a33b00033b46c698ff6340d95569c13">samples::findFile</a>(vocPath));</div><div class="line">    <a class="code" href="../../db/de0/group__core__utils.html#gaf62bcd90f70e275191ab95136d85906b">CV_Assert</a>(vocFile.is_open());</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> vocLine;</div><div class="line">    std::vector&lt;String&gt; vocabulary;</div><div class="line">    <span class="keywordflow">while</span> (std::getline(vocFile, vocLine)) {</div><div class="line">        vocabulary.push_back(vocLine);</div><div class="line">    }</div><div class="line">    recognizer.setVocabulary(vocabulary);</div><div class="line">    recognizer.setDecodeType(<span class="stringliteral">&quot;CTC-greedy&quot;</span>);</div><div class="line"></div><div class="line">    <span class="comment">// Parameters for Recognition</span></div><div class="line">    <span class="keywordtype">double</span> recScale = 1.0 / 127.5;</div><div class="line">    <a name="_a7"></a><a class="code" href="../../d1/da0/classcv_1_1Scalar__.html">Scalar</a> recMean = <a name="a8"></a><a class="code" href="../../dc/d84/group__core__basic.html#ga599fe92e910c027be274233eccad7beb">Scalar</a>(127.5, 127.5, 127.5);</div><div class="line">    <a name="_a9"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> recInputSize = <a name="a10"></a><a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(100, 32);</div><div class="line">    recognizer.setInputParams(recScale, recInputSize, recMean);</div><div class="line"></div><div class="line">    <span class="comment">// Parameters for Detection</span></div><div class="line">    <span class="keywordtype">double</span> detScale = 1.0;</div><div class="line">    <a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> detInputSize = <a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(width, height);</div><div class="line">    <a class="code" href="../../d1/da0/classcv_1_1Scalar__.html">Scalar</a> detMean = <a class="code" href="../../dc/d84/group__core__basic.html#ga599fe92e910c027be274233eccad7beb">Scalar</a>(123.68, 116.78, 103.94);</div><div class="line">    <span class="keywordtype">bool</span> swapRB = <span class="keyword">true</span>;</div><div class="line">    detector.setInputParams(detScale, detInputSize, detMean, swapRB);</div><div class="line"></div><div class="line">    <span class="comment">// Open a video file or an image file or a camera stream.</span></div><div class="line">    <a name="_a11"></a><a class="code" href="../../d8/dfe/classcv_1_1VideoCapture.html">VideoCapture</a> cap;</div><div class="line">    <span class="keywordtype">bool</span> openSuccess = parser.has(<span class="stringliteral">&quot;input&quot;</span>) ? cap.<a name="a12"></a><a class="code" href="../../d8/dfe/classcv_1_1VideoCapture.html#a614a1702e15f42ede5100014ce7f48ed">open</a>(parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;input&quot;</span>)) : cap.<a class="code" href="../../d8/dfe/classcv_1_1VideoCapture.html#a614a1702e15f42ede5100014ce7f48ed">open</a>(0);</div><div class="line">    <a class="code" href="../../db/de0/group__core__utils.html#gaf62bcd90f70e275191ab95136d85906b">CV_Assert</a>(openSuccess);</div><div class="line"></div><div class="line">    <span class="keyword">static</span> <span class="keyword">const</span> std::string kWinName = <span class="stringliteral">&quot;EAST: An Efficient and Accurate Scene Text Detector&quot;</span>;</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> frame;</div><div class="line">    <span class="keywordflow">while</span> (<a name="a13"></a><a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">waitKey</a>(1) &lt; 0)</div><div class="line">    {</div><div class="line">        cap &gt;&gt; frame;</div><div class="line">        <span class="keywordflow">if</span> (frame.empty())</div><div class="line">        {</div><div class="line">            <a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">waitKey</a>();</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        std::cout &lt;&lt; frame.size &lt;&lt; std::endl;</div><div class="line"></div><div class="line">        <span class="comment">// Detection</span></div><div class="line">        std::vector&lt; std::vector&lt;Point&gt; &gt; detResults;</div><div class="line">        detector.detect(frame, detResults);</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (detResults.size() &gt; 0) {</div><div class="line">            <span class="comment">// Text Recognition</span></div><div class="line">            <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> recInput;</div><div class="line">            <span class="keywordflow">if</span> (!imreadRGB) {</div><div class="line">                <a name="a14"></a><a class="code" href="../../d8/d01/group__imgproc__color__conversions.html#ga397ae87e1288a81d2363b61574eb8cab">cvtColor</a>(frame, recInput, <a name="a15"></a><a class="code" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a353a4b8db9040165db4dacb5bcefb6ea">cv::COLOR_BGR2GRAY</a>);</div><div class="line">            } <span class="keywordflow">else</span> {</div><div class="line">                recInput = frame;</div><div class="line">            }</div><div class="line">            std::vector&lt; std::vector&lt;Point&gt; &gt; contours;</div><div class="line">            <span class="keywordflow">for</span> (<a class="code" href="../../d1/d1b/group__core__hal__interface.html#ga4f5fce8c1ef282264f9214809524d836">uint</a> i = 0; i &lt; detResults.size(); i++)</div><div class="line">            {</div><div class="line">                <span class="keyword">const</span> <span class="keyword">auto</span>&amp; quadrangle = detResults[i];</div><div class="line">                <a name="a16"></a><a class="code" href="../../d1/d26/check_8hpp.html#a61c25240a2aa49578c51fae675350615">CV_CheckEQ</a>(quadrangle.size(), (size_t)4, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line">                contours.emplace_back(quadrangle);</div><div class="line"></div><div class="line">                std::vector&lt;Point2f&gt; quadrangle_2f;</div><div class="line">                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 4; j++)</div><div class="line">                    quadrangle_2f.emplace_back(quadrangle[j]);</div><div class="line"></div><div class="line">                <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cropped;</div><div class="line">                fourPointsTransform(recInput, &amp;quadrangle_2f[0], cropped);</div><div class="line"></div><div class="line">                std::string recognitionResult = recognizer.recognize(cropped);</div><div class="line">                std::cout &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot;: &#39;&quot;</span> &lt;&lt; recognitionResult &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span> &lt;&lt; std::endl;</div><div class="line"></div><div class="line">                <a name="a17"></a><a class="code" href="../../d6/d6e/group__imgproc__draw.html#ga5126f47f883d730f633d74f07456c576">putText</a>(frame, recognitionResult, quadrangle[3], <a name="a18"></a><a class="code" href="../../d6/d6e/group__imgproc__draw.html#gga0f9314ea6e35f99bb23f29567fc16e11afff8b973668df2e4028dddc5274310c9">FONT_HERSHEY_SIMPLEX</a>, 1.5, <a class="code" href="../../dc/d84/group__core__basic.html#ga599fe92e910c027be274233eccad7beb">Scalar</a>(0, 0, 255), 2);</div><div class="line">            }</div><div class="line">            <a name="a19"></a><a class="code" href="../../d6/d6e/group__imgproc__draw.html#ga1ea127ffbbb7e0bfc4fd6fd2eb64263c">polylines</a>(frame, contours, <span class="keyword">true</span>, <a class="code" href="../../dc/d84/group__core__basic.html#ga599fe92e910c027be274233eccad7beb">Scalar</a>(0, 255, 0), 2);</div><div class="line">        }</div><div class="line">        <a name="a20"></a><a class="code" href="../../d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563">imshow</a>(kWinName, frame);</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> fourPointsTransform(<span class="keyword">const</span> <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; frame, <span class="keyword">const</span> <a class="code" href="../../db/d4e/classcv_1_1Point__.html">Point2f</a> vertices[], <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; result)</div><div class="line">{</div><div class="line">    <span class="keyword">const</span> <a class="code" href="../../d6/d50/classcv_1_1Size__.html">Size</a> outputSize = <a class="code" href="../../dc/d84/group__core__basic.html#ga346f563897249351a34549137c8532a0">Size</a>(100, 32);</div><div class="line"></div><div class="line">    <a class="code" href="../../db/d4e/classcv_1_1Point__.html">Point2f</a> targetVertices[4] = {</div><div class="line">        <a name="a21"></a><a class="code" href="../../dc/d84/group__core__basic.html#ga1e83eafb2d26b3c93f09e8338bcab192">Point</a>(0, outputSize.<a name="a22"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html#a1d289dce6b5d8006a54f3ee0259fc545">height</a> - 1),</div><div class="line">        <a class="code" href="../../dc/d84/group__core__basic.html#ga1e83eafb2d26b3c93f09e8338bcab192">Point</a>(0, 0), <a class="code" href="../../dc/d84/group__core__basic.html#ga1e83eafb2d26b3c93f09e8338bcab192">Point</a>(outputSize.<a name="a23"></a><a class="code" href="../../d6/d50/classcv_1_1Size__.html#abfe0367b32c407ddccf5ddf92667c73d">width</a> - 1, 0),</div><div class="line">        <a class="code" href="../../dc/d84/group__core__basic.html#ga1e83eafb2d26b3c93f09e8338bcab192">Point</a>(outputSize.<a class="code" href="../../d6/d50/classcv_1_1Size__.html#abfe0367b32c407ddccf5ddf92667c73d">width</a> - 1, outputSize.<a class="code" href="../../d6/d50/classcv_1_1Size__.html#a1d289dce6b5d8006a54f3ee0259fc545">height</a> - 1)</div><div class="line">    };</div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> rotationMatrix = <a name="a24"></a><a class="code" href="../../da/d54/group__imgproc__transform.html#ga20f62aa3235d869c9956436c870893ae">getPerspectiveTransform</a>(vertices, targetVertices);</div><div class="line"></div><div class="line">    <a name="a25"></a><a class="code" href="../../da/d54/group__imgproc__transform.html#gaf73673a7e8e18ec6963e3774e6a94b87">warpPerspective</a>(frame, result, rotationMatrix, outputSize);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:29 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
